package mypaint;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.example.johnsun.mytestapp.R;


/**
 * Created by JohnSun on 2016/1/29.
 */
public class PaintTest extends Activity implements View.OnClickListener {
    LinearLayout linearLayout;
     MyView myView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        setContentView(R.layout.my_paint);
        Button button= (Button) findViewById(R.id.return_button);
                button.setOnClickListener(this);
        findViewById(R.id.paint_pen).setOnClickListener(this);
        findViewById(R.id.eraser).setOnClickListener(this);
        findViewById(R.id.clean).setOnClickListener(this);
        findViewById(R.id.color1).setOnClickListener(this);
        findViewById(R.id.color2).setOnClickListener(this);
        findViewById(R.id.color3).setOnClickListener(this); findViewById(R.id.color4).setOnClickListener(this);
        findViewById(R.id.color5).setOnClickListener(this); findViewById(R.id.color6).setOnClickListener(this);
        findViewById(R.id.color7).setOnClickListener(this); findViewById(R.id.color8).setOnClickListener(this);
        //  myView= (MyView) findViewById(R.id.my_view);  myView.setOnClickListener(this);
        myView = new MyView(getApplicationContext());
       myView.setBackgroundColor(Color.TRANSPARENT);

        // 将view加入到布局中
        linearLayout = (LinearLayout) findViewById(R.id.linearlayout01);
        //
        // linearLayout.removeAllViews();
       // linearLayout.addView(myView);


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.return_button:
                break;
            case R.id.paint_pen:

                new PaintPWindow(this,v).show();


              DrawScrawl.paintSize =60;//简单直接

                break;
            case R.id.eraser:
               // myView.setDrawTool(10);
               DrawPath.eraserSize=50;


                break;
            case R.id.clean:
                linearLayout.removeAllViews();
                myView = new MyView(getApplicationContext());
                linearLayout.addView(myView);
                break;
            //颜色选择
            case R.id.color1:
             myView.setColorTool(0);
                break;
            case R.id.color2:
              myView.setColorTool(1);
                break;
            case R.id.color3:
               myView.setColorTool(2);
                break;
            case R.id.color4:
                myView.setColorTool(3);
                break;
        }
    }








}
